<template>
    <div class="navigator">
        <div
            class="row body"
            :class="{
                'body-light': mode === 'light',
                'body-dark': mode === 'dark',
            }"
        >
            <!-- 返回按钮 -->
            <div v-if="leftButton === 'back'" class="left btn-back" @click="onPageBack">
                <img v-if="mode === 'light'" :src="require('@/assets/icon/page_back_light.png')" />
                <img v-if="mode === 'dark'" :src="require('@/assets/icon/page_back_dark.png')" />
            </div>

            <!-- 占位区域 -->
            <div v-if="leftButton === 'none'" class="left none"></div>

            <!-- 中间区域 -->
            <div class="nav-center">
                <slot name="center"></slot>
            </div>

            <!-- 右边区域 -->
            <div class="nav-right">
                <slot name="right"></slot>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        mode: {
            type: String,
            default: "light" // dark
        },
        leftButton: {
            type: String,
            default: "back"
        }
    },
    data() {
        return {};
    },

    methods: {
        onPageBack() {
            this.$router.go(-1);
        }
    }
};
</script>


<style lang="less" scoped>
.navigator {
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100px;

    .body {
        box-sizing: border-box;
        height: 100%;
        padding: 20px 0;
        justify-content: space-between;
        align-items: center;
        .left {
            z-index: 2;
            position: absolute;
            left: 30px;
            width: 40px;
            height: 40px;
        }

        .nav-center {
            z-index: 1;
            position: absolute;
            width: 100%;
            text-align: center;
        }

        .nav-right {
            z-index: 2;
            position: absolute;
            right: 30px;
        }
    }

    .body-light {
        background: #fff;
    }

    .body-dark {
        background: #333;
    }
}
</style>